﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <script src="/js/header.js"></script>
    <script src="/lib/date/wdatepicker.js"></script>
</head>
<body>
    <div class="data-wrap case">
        <div class="data-tool clearfix">
            <div class="pull-left form-inline ">

            </div>
            <div class="pull-right">

                <form class="form-inline" id="formSearch" onsubmit="return false;">

                    <div class="input-group input-group-sm">
                        <div class="input-sm"><input name="autoRefresh" type="checkbox" title="10秒自动刷新" /> <label id="time" class="wd100">10秒自动刷新</label></div>
                    </div>

                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">公司名称：</label>
                        <input class="form-control" id="companyName" name="companyName" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行名称：</label>
                        <input class="form-control" name="bankName" type="text" autocomplete="off" />
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">银行卡号：</label>
                        <input class="form-control" name="cardNumber" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">用户名：</label>
                        <input class="form-control" name="cardName" type="text" autocomplete="off">
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">启用状态：</label>
                        <select class="form-control" name="enableStatus">
                            <option value="">请选择</option>
                            <option value="1">启用</option>
                            <option value="2">禁用</option>
                        </select>
                    </div>
                    <div class="input-group input-group-sm">
                        <label class="input-group-addon m5_l">更新时间：</label>
                        <select class="form-control" name="lastUpdateDateSortType">
                            <option value="">请选择</option>
                            <option value="2" selected>不正常</option>
                            <option value="1">正常</option>
                        </select>
                    </div>
                    <button type="button" class="btn btn-default btn-sm active" id="btnSearch"><span class="glyphicon glyphicon-search"></span> 搜索</button>
                </form>
            </div>
        </div>

        <div class="paging">
        </div>
    </div>

    <script type="text/x-dot-template" id="pgerTemplate">

        <div class="data-body data-scroll">
            <div class="data-view">
                <div class="data-div-view table-responsive">
                    <table class="table table-hover table-striped table-bordered">
                        <thead>
                            <tr>
                                <th class="t_l wd100">公司名称</th>
                                <th class="t_l wd100">银行名称</th>
                                <th class="t_l wd125">银行卡号</th>
                                <th class="t_l wd75">用户名</th>
                                <th class="t_l wd75">付款类型</th>
                                <th class="t_c wd75">使用状态</th>
                                <th class="t_c wd75">启用状态</th>
                                <th class="t_c wd125">成功笔数 / 金额</th>
                                <th class="t_r bold wd75">参考余额</th>
                                <th class="t_r wd130">付款区间起迄</th>
                                <!--<th class="t_c wd100">付款费率(%)</th>-->
                                <th class="wd130">更新时间</th>
                                <th class="t_l wd125">付款等级</th>
                                <th class="wd75">跨行转账</th>
                                <th class="t_l wd100">虚拟机编码</th>
                                <th class="t_l wd125">备注</th>
                                <th class="wd150">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {{? it.tData && it.tData.length>0}}
                            {{~it.tData :item:index}}
                            <tr>
                                <td class="t_l wd100" title="{{= item.companyNameEn }}">{{= item.companyName }}</td>
                                <td class="t_l wd100" title="{{= item.bankName }}">{{= item.bankName }}</td>
                                <td class="t_l wd125" title="{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}">{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}</td>
                                <td class="t_l wd75">{{= item.cardName }}</td>
                                <td class="t_l wd75">{{= item.paymentTypeName }}</td>
                                <td class="t_c wd75">

                                    {{?  item.usingStatus}}
                                    {{? item.usingStatus==1 }}
                                    <span class="green bold">有效</span>
                                    {{?? }}
                                    <span class="red bold">冻结</span>
                                    {{? }}
                                    {{??}}

                                    {{?}}

                                </td>
                                <td class="t_c wd75">

                                    {{?  item.usingStatus}}
                                    {{? item.enableStatus==1 }}
                                    <span class="green bold">启用</span>
                                    {{?? item.enableStatus==2}}
                                    <span class="red bold">禁用</span>
                                    {{??}}
                                    <span class="red bold">删除</span>
                                    {{? }}
                                    {{??}}

                                    {{?}}


                                </td>
                                <td class="t_r bold wd125">{{= item.quantity }} / {{=item.withdrawalAmount}}</td>
                                <td class="t_r bold wd75" {{= item.adjustBalanceRid!=null?"style=\"background-color:red;color:white\"":"" }}>{{?  item.balance}}{{= item.balance }}{{??}}{{?}}</td>
                                <td class="t_r wd130">{{?  item.paymentInterval}}{{= item.paymentInterval }}{{??}}{{?}}</td>
                                <!--<td class="t_c wd100">{{?  item.payFeeRatio}}{{= FlashPay.Util.FormatNumber(item.payFeeRatio) }}(%){{??}}0.00(%){{?}}</td>-->
                                <td class="wd150" {{= (item.timeDifference>=5 && item.enableStatus==1)?"style=\"background-color:red;color:white\"":"" }}>
                                    {{?  item.balanceLastUpdate}}{{= item.balanceLastUpdate }}{{??}}{{?}}
                                </td>
                                <td class="t_l wd125">{{?  item.depositType}}{{= item.depositType }}{{??}}{{?}}</td>
                                <td class="wd75">
                                    {{?  item.usingStatus}}
                                    {{? item.crossBankPay==1 }}
                                    同行
                                    {{?? item.crossBankPay==2}}
                                    跨行
                                    {{??}}
                                    全部
                                    {{? }}
                                    {{??}}

                                    {{?}}
                                </td>
                                <td class="t_l wd100" title="{{?  item.vmClientId}}{{= item.vmClientId }}{{??}}{{?}}">
                                    {{?  item.vmClientId}}{{= item.vmClientId }}{{??}}{{?}}
                                </td>
                                <td class="t_l wd125" title="{{?  item.remark}}{{= item.remark }}{{??}}{{?}}">
                                    {{?  item.remark}}{{= item.remark }}{{??}}{{?}}

                                </td>
                                <td class="wd150">
                                    {{? item.enableStatus==1 }}
                                    <a class="btn btn-warning btn-xs" data-confirm=' "{{= item.cardName }}" <br>确定要<span class="orange">禁用</span>该银行卡？' data-href="/Payment/PaymentCardUpdateStatus?id={{= item.bcId}}&status=2">禁用</a>
                                    {{?? }}
                                    <a class="btn btn-success btn-xs" data-confirm=' "{{= item.cardName }}" <br>确定要<span class="orange">启用</span>该银行卡？' data-href="/Payment/PaymentCardUpdateStatus?id={{= item.bcId}}&status=1">启用</a>
                                    <button type="button" class="btn btn-default btn-xs" data-modal="/view/payment/paymentcardEdit.html?id={{= item.bcId}}" data-title="编辑 - {{= item.bankName }}-{{= item.cardName }}-{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}" data-width="452" data-height="380">
                                        <span class="glyphicon glyphicon-edit"></span> 编辑
                                    </button>
                                    {{? }}
                                    {{? item.adjustBalanceRid!=null}}<button type="button" class="btn btn-warning btn-xs" data-modal="/view/payment/paymentcardException.html?backCardId={{= item.bcId}}&adjustBalanceRid={{= item.adjustBalanceRid}}" data-confirmname="已处理" data-title="异常 - {{= item.bankName }}-{{= item.cardName }}-{{= FlashPay.Util.SubCardNumber(item.cardNumber) }}" data-width="1200" data-height="120">异常</button>{{?}}
                                </td>
                            </tr>
                            {{~}}
                            {{??}}
                            <tr class="noRecord">
                                <td colspan="16">暂无记录！</td>
                            </tr>
                            {{?}}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!-- 必要的分页参数设置 -->
        <input type="hidden" id="TotalCount" value="{{=it.totalCount}}" />
    </script>
    <script type="text/javascript">

        var wait = 10;

        var autoRefresh = $("input[name='autoRefresh']");

        $(function () {

            FlashPay.UI.DataAutoHeight();

            $("#btnSearch").click(function () {
                
                window.currentPage = null;

                doSearch();
            });

            FlashPay.UI.DoSearch();

            $(autoRefresh).change(function () {
                wait = 10;
                time();
            });

            
        });

        //倒时计
        function time() {
            var obj = document.getElementById("time");

            var isauto = $(autoRefresh).is(':checked');
            if (!isauto) {

                obj.innerText = "10秒自动刷新";

                return false;
            }

            if (wait == 0) {
                obj.innerText = "10秒自动刷新";
                wait = 10;

                if (isauto) {
                    setTimeout(function () { time(); }, 1000);
                }

                FlashPay.UI.DoSearch();
            } else {
                obj.innerText = wait + "秒自动刷新";
                wait--;
                setTimeout(function () { time(); }, 1000);
            }
        }

        $(document).keyup(function (event) {
            var keycode = event.which;
            if (keycode == 13) {
                FlashPay.UI.DoSearch();
            }
        });

        function Tip_success(word) {
            FlashPay.UI.Tip_success(word);
        }

        function doSearch() {

            emptyCompanyId();

            FlashPay.UI.Pager(".paging", { templateId: "pgerTemplate", pageSize:15, ajax: { url: '/Payment/PaymentCardPager'} });
        }

        $("#companyName").autocomplete({
            minLength: 1,
            select: function (event, ui) {
                $("input[name='companyId']").val(ui.item.id);
            },
            source: function (request, response) {
                FlashPay.Util.Ajax({
                    url: '/Role/CompanySearch',
                    type: 'POST',
                    data: {
                        companyName: $("#companyName").val()
                    },
                    success: function (res) {
                        if (res.success) {
                            if (res.data != null && res.data.length > 0) {
                                response($.map(res.data, function (item) {
                                    return {
                                        label: item.companyName,
                                        value: item.companyName,
                                        id: item.companyID
                                    }
                                }))
                            }
                        } else {
                            FlashPay.UI.Tip_warning("操作失败！" + res.errorMessage);
                        }
                    },
                    error: function (json) {
                        FlashPay.UI.Tip_warning("操作失败！请查看网络，请重试。");
                    }
                });
            }
        });

        function emptyCompanyId() {

            var company = $("#company").val();;

            if (FlashPay.Util.isNullOrEmptySpance(company)) {
                $("input[name='companyId']").val("");
            }
        }
    </script>
</body>
</html>